import java.util.Scanner;

public class PlayFile {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String file = null;
        String fileName = null;
        String audioType = null;
        AudioPlayer player = null;
        System.out.printf("正在测试播放音乐输入filename.stop暂停,输入end结束%n");
        while (input.hasNext()) {
            file = input.nextLine();
            if (!file.equals("end")) {
                fileName = file.substring(0, file.indexOf('.'));
                audioType = file.substring(file.indexOf('.') + 1);
                player = new AudioPlayer();
                if(audioType.equalsIgnoreCase("stop")){
                    player.stop(fileName);
                }else{
                    player.play(audioType, fileName);
                }
            } else {
                break;
            }
        }
        input.close();
    }
}